{% extends 'base.html' %}


{% block body %}
<div class="container">
    <form action="/semi/label/{{ rid }}" method="POST" id="form" name="{{ rid }}" onsubmit="return onSubmit(this);">

        <div class="container">
            <div class="card">
                <div class="card-body">
                    <p>
                        {{ content | safe}}
                    </p>
                </div>
                <div class="card-footer text-muted">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm">
                                <div class="row">
                                </div>
                            </div>

                            <div class="col-sm">
                                <div class="float-right">
                                    <!-- <fieldset> -->
                                    <div class="btn-group btn-group-toggle" data-toggle="buttons">
                                        <label class="btn btn-secondary" for="{{ rid }}-T">
                                            <input type="radio" name="{{ rid }}" id="{{ rid }}-T" value=1 checked> 水
                                        </label>
                                        <label class="btn btn-secondary" for="{{ rid }}-F">
                                            <input type="radio" name="{{ rid }}" id="{{ rid }}-F" value=0> 不水
                                        </label>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="container">
            <div class="col m-3">
                <div class="col-sm-4 mx-auto">
                    <button type="submit" id="submit" class="btn btn-warning btn-block btn-lg">
                        提交
                    </button>
                </div>
            </div>
        </div>

        <div class="modal" tabindex="-1" role="dialog" id="modal">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">提交结果</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <p id="return-message">Modal body text goes here.</p>
                    </div>
                    <div class="modal-footer">
                        <a row="button" class="btn btn-primary" href="{{ url_for('semi_detail') }}">
                            下一篇
                        </a>
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>

        <script>
            function onSubmit(form) {
                $(form).ajaxSubmit(function (message) {
                    $("#return-message").text(message);
                    $("#modal").modal()
                })
                return false;
            }
            $(document).ready(function () {

                {% if predict == None %}

                $('#{{ rid }}-F').parent().addClass('active')
                $('#{{ rid }}-F').prop('checked', true)

                {% elif predict > 0.8 %}

                $('#{{ rid }}-T').parent().addClass('active')
                $('#{{ rid }}-T').prop('checked', true)

                {% elif predict < 0.2 %}

                $('#{{ rid }}-F').parent().addClass('active')
                $('#{{ rid }}-F').prop('checked', true)

                {% endif %}

            })

        </script>
    </form>

</div>
{% endblock %}